###-*-makefile-*-   ; force emacs to enter makefile-mode


PREFIX             = @prefix@
prefix             = ${PREFIX}
ETCDIR             = @sysconfdir@
VARDIR             = @localstatedir@

ifeq ($(DESTDIR),)
 DESTDIR=/
endif

## DESTDIR is handled separately in the individual Makefiles

ERL=@ERL@
WERL=@WERL@
ERLC=@ERLC@
EMULATOR=beam
DEFAULT_CHARSET=@DEFAULT_CHARSET@
EPAM = @EPAM@
EXTRAINCLUDE = @EXTRAINCLUDE@
ERLBINDIR = @ERLBINDIR@


ifdef debug
  ERLC_FLAGS+=-Ddebug
endif

ifdef trace
  ERLC_FLAGS=+trace
endif

ifdef export_all
  ERLC_FLAGS+=-Dexport_all
endif

ifdef debug_info
  ERLC_FLAGS+=+debug_info
endif

CC=@CC@
CFLAGS=@CFLAGS@
LINKER=@LINKER@
LDFLAGS=@LDFLAGS@
WIN32=@WIN32@
BSDI=@BSDI@
EXE=@EXE@
DLL=@DLL@
OBJ=@OBJ@
OUT=@OUT@
FPIC=@FPIC@
LIBS=@LIBS@



ERLDIR=@ERLDIR@

LD_SHARED=@LD_SHARED@

INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@



EMULATOR=beam
ifdef debug
  ERLC_FLAGS+=-Ddebug
endif

ifdef trace
  ERLC_FLAGS=+trace
endif

ifdef export_all
  ERLC_FLAGS+=-Dexport_all
endif


# Hmm, don't know if you are supposed to like this better... ;-)
APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'

# Targets

../ebin/%.app: %.app.src ../vsn.mk Makefile
	perl -e $(APPSCRIPT) "$(VSN)" $(MODULES) < $< > $@

../ebin/%.appup: %.appup 
	cp $< $@

../ebin/%.$(EMULATOR): %.erl
	"$(ERLC)" $(ERLC_FLAGS) -o ../ebin $<

%.$(EMULATOR): %.erl
	"$(ERLC)" $(ERLC_FLAGS) $<



